<template>
  <div class="container">
    <el-card shadow="always">
      <el-row :gutter="20">
        <el-col :span="6">
          <el-input
            maxlength="50"
            v-model="query.complaintUnit"
            clearable
            placeholder="请输入被投诉单位名称"
          ></el-input>
        </el-col>
        <el-col :span="2">
          <el-button type="primary" @click="query.pageIndex=1;getList()">查询</el-button>
        </el-col>
      </el-row>
      <rz-height></rz-height>

      <el-table :data="tableData" border style="width: 100%">
        <el-table-column prop="registerData" label="登记日期"> </el-table-column>
        <el-table-column prop="registrant" label="登记人"> </el-table-column>
        <el-table-column prop="complaintUnit" label="投诉单位"> </el-table-column>
        <el-table-column prop="complaintCategory" label="投诉类别"> </el-table-column>
        <el-table-column prop="processingResults" label="处理结果"> </el-table-column>
        <el-table-column prop="" label="操作">
          <template slot-scope="scope">
            <el-button size="mini" type="primary" @click="view(scope.row)"
              >查看</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <pagination
        :total="total"
        @pagination="getList"
        :page.sync="query.pageIndex"
      />
    </el-card>
    <rz-dialog
      :dialogVisible.sync="dialogVisible"
      :isShowConfirm="false"
      title="查看食安检测"
    >
      <el-form label-width="120px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="登记日期">
              {{ data.registerData }}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="登记人">
              {{ data.registrant }}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="投诉类型"> {{ data.complaintCategory }} </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="投诉人">
              {{ data.complainant }}
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="联系方式">
              {{ data.contactTel }}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="投诉单位">
              {{ data.complaintUnit }}
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="投诉内容及要求">
              {{ data.complaintContent }}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="情况核实">
              {{ data.situationVerification }}
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="处理意见">
              {{ data.handlingOpinions }}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="处理结果">
              {{ data.processingResults }}
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>





    </rz-dialog>
  </div>
</template>
<script>
//
import {
  complaintFindListByCondition,
  complaintFindById,
} from "@/api/modules/workstation";
export default {
  // props:[],
  // 页面加载
  created() {
    this.getList();
  },
  // 页面加载完成
  mounted() {},
  //实例销毁之前
  beforeDestroy() {},
  //实例销毁后
  destroyed() {},
  data() {
    return {
      //   options: ["合格", "不需要考核"],
      query: {
        // isLogin: "-1",
        // isPublicity: "-1",
        // isTrain: "-1",
        // isPage: 0,
        // page: 1,
        // pageSize: 10,
        // searchValue: "",
        // workStationId: sessionStorage.getItem("workId"),
        complaintCategory: "",
        complaintUnit: "",
        pageIndex: 1,
        pageSize: 10,
        processingResults: "",
        registerData: "",
        registrant: "",
        workStationId: sessionStorage.getItem("workId"),
        workStationName: sessionStorage.getItem("unitName"),
      },
      tableData: [],
      total: 0,
      dialogVisible: false,
      data: {},
    };
  },
  // 方法
  methods: {
    getList() {
      complaintFindListByCondition(this.query).then((res) => {
        // res.data.forEach((x) => {
        //   for (const key in x) {
        //     if (!x[key]) {
        //       x[key] = "--";
        //     }
        //   }
        // });
        this.total = res.totalCount;
        this.tableData = res.data;
      });
    },
    view(e) {
      complaintFindById({
        params: { id: e.id },
      }).then((res) => {
          for (const key in  res.data) {
            if (!res.data[key]) {
              res.data[key] = "--";
            }
          }
        this.data = res.data;
        this.dialogVisible = true;
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.title {
  font-weight: 700;
  font-size: 16px;
}
</style>